package com.nova.scenic.projectlibs.util.lifecyclehelper;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.IBinder;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.ContextMenu;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;

import java.io.FileDescriptor;
import java.io.PrintWriter;

public class LifeCycleHelperBase implements LifeCycleHelper {

    LifeCycleHelper helper;

    public LifeCycleHelperBase(LifeCycleHelper helper) {
        this.helper = helper;
    }

    @Override
    public void attachBaseContext(Context context) {
        if (helper != null) {
            helper.attachBaseContext(context);
        }
    }

    @Override
    public void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
        if (helper != null) {
            helper.onApplyThemeResource(theme, resid, first);
        }

    }

    @Override
    public void onCreate() {
        if (helper != null) {
            helper.onCreate();
        }
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        if (helper != null) {
            helper.onStartCommand(intent,flags,startId);
        }
        return 0;
    }

    @Override
    public void onStart(Intent intent, int startId) {
        if (helper != null) {
            helper.onStart(intent,startId);
        }
    }

    @Override
    public boolean onUnbind(Intent intent) {
        if (helper != null) {
            helper.onUnbind(intent);
        }
        return false;
    }

    @Override
    public IBinder onBind(Intent intent) {
        if (helper != null) {
            helper.onBind(intent);
        }
        return null;
    }

    @Override
    public void onTaskRemoved(Intent rootIntent) {
        if (helper != null) {
            helper.onTaskRemoved(rootIntent);
        }
    }

    @Override
    public void onRebind(Intent intent) {
        if (helper != null) {
            helper.onRebind(intent);
        }
    }

    @Override
    public void onHandleIntent(Intent intent) {
        if (helper != null) {
            helper.onHandleIntent(intent);
        }
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        if (helper != null) {
            helper.onConfigurationChanged(newConfig);
        }
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        if (helper != null) {
            helper.onCreate(savedInstanceState);
        }
    }

    @Override
    public void onDestroy() {
        if (helper != null) {
            helper.onDestroy();
        }

    }

    @Override
    public void onResume() {
        if (helper != null) {
            helper.onResume();
        }

    }

    @Override
    public void onPause() {
        if (helper != null) {
            helper.onPause();
        }

    }

    @Override
    public void onStart() {
        if (helper != null) {
            helper.onStart();
        }

    }

    @Override
    public void onStop() {
        if (helper != null) {
            helper.onStop();
        }

    }

    @Override
    public void onRestart() {
        if (helper != null) {
            helper.onRestart();
        }
    }

    @Override
    public void onNewIntent(Intent intent) {
        if (helper != null) {
            helper.onNewIntent(intent);
        }

    }

    @Override
    public void onRestoreInstanceState(Bundle savedInstanceState) {
        if (helper != null) {
            helper.onRestoreInstanceState(savedInstanceState);
        }

    }

    @Override
    public void onAttach(Context activity) {
        if (helper != null) {
            helper.onAttach(activity);
        }
    }

    @Override
    public void onAttach(Activity activity) {
        if (helper != null) {
            helper.onAttach(activity);
        }
    }

    @Override
    public void onDetach() {
        if (helper != null) {
            helper.onDetach();
        }
    }

    @Override
    public void onViewStateRestored(@Nullable Bundle savedInstanceState) {
        if (helper != null) {
            helper.onViewStateRestored(savedInstanceState);
        }
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        if (helper != null) {
            helper.onSaveInstanceState(outState);
        }

    }

    @Override
    public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
        if (helper != null) {
            helper.onCreateContextMenu(menu, v, menuInfo);
        }
    }

    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        if (helper != null) {
            helper.onCreateOptionsMenu(menu, inflater);
        }
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        if (helper != null) {
            helper.onViewCreated(view, savedInstanceState);
        }
    }

    @Override
    public void onLowMemory() {
        if (helper != null) {
            helper.onLowMemory();
        }
    }

    @Override
    public void onDestroyView() {
        if (helper != null) {
            helper.onDestroyView();
        }
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        if (helper != null) {
            helper.onActivityCreated(savedInstanceState);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        if (helper != null) {
            helper.onCreateView(inflater, container, savedInstanceState);
        }
        return null;
    }

    @Override
    public void onDestroyOptionsMenu() {
        if (helper != null) {
            helper.onDestroyOptionsMenu();
        }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (helper != null) {
            helper.onActivityResult(requestCode, resultCode, data);
        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        if (helper != null) {
            onRequestPermissionsResult(requestCode, permissions, grantResults);
        }
    }

    @Override
    public void onAttachedToWindow() {
        if (helper != null) {
            helper.onAttachedToWindow();
        }

    }

    @Override
    public void onDetachedFromWindow() {
        if (helper != null) {
            helper.onDetachedFromWindow();
        }

    }

    @Override
    public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {
        if (helper != null) {
            helper.onCreateView(parent, name, context, attrs);
        }

        return null;
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        if (helper != null) {
            helper.onCreateOptionsMenu(menu);
        }
        return false;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (helper != null) {
            helper.onOptionsItemSelected(item);
        }
        return false;
    }

    @Override
    public boolean onGenericMotionEvent(MotionEvent event) {
        if (helper != null) {
            helper.onGenericMotionEvent(event);
        }

        return false;
    }

    @Override
    public void onTrimMemory(int level) {
        if (helper != null) {
            helper.onTrimMemory(level);
        }

    }

    @Override
    public boolean dispatchGenericMotionEvent(MotionEvent ev) {
        if (helper != null) {
            helper.dispatchGenericMotionEvent(ev);
        }

        return false;
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        if (helper != null) {
            helper.dispatchTouchEvent(ev);
        }

        return false;
    }

    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        if (helper != null) {
            helper.dispatchKeyEvent(event);
        }

        return false;
    }

    @Override
    public void onActivityFinish() {
        if (helper != null) {
            helper.onActivityFinish();
        }
    }

    @Override
    public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) {
        if (helper != null) {
            helper.dump(prefix, fd, writer, args);
        }


    }

}